2. Adding Navigation to Search Center Master Page
Although the master page minimal.master
has no navigation, it is possible to add it. This is recommended for
most corporations. Assume a user executes a search, gets some search
results, and then wants to jump back to the root site. The only way is
for the user to modify the URL manually, which is not really a feasible
option.
To add navigation to the minimal.master, first locate this section in the master page.
<div>
<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server" />
</div>
Add the following markup from Listing 2 just before the foregoing markup. This places the navigation in the correct location for it to show properly.
Example 2. Navigation in minimal.master Master Page Markup
<div id="s4-topheader2" class="s4-pr s4-notdlg"> <div class="s4-lp s4-toplinks"> <asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server"> <asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server"> <SharePoint:AspMenu ID="TopNavigationMenuV4" Runat="server" EnableViewState="false" DataSourceID="topSiteMap" AccessKey="<%$Resources:wss,navigation_accesskey%>" UseSimpleRendering="true" UseSeparateCss="false" Orientation="Horizontal" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="1" SkipLinkText="" CssClass="s4-tn"/> <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate"> <Template_Controls> <asp:SiteMapDataSource ShowStartingNode="False" SiteMapProvider="SPNavigationProvider" id="topSiteMap" runat="server" StartingNodeUrl="sid:1002"/> </Template_Controls> </SharePoint:DelegateControl> </asp:ContentPlaceHolder> </asp:ContentPlaceHolder> </div> </div>
|
Then locate this section in the minimal.master.
<SharePoint:CssRegistration Name="layouts.css" runat="server"/>
Add this just before the foregoing.
<SharePoint:CssRegistration Name="corev4.css" runat="server"/>
After these changes, the minimal.master now includes navigation as seen in Figure 5. As it is only the search center that uses the minimal.master,
it is suggested that this master page is deployed throughout the farm
to solve the missing navigation issue for all search centers, both
current and the ones created later.
3. Adding Navigation to the SearchMain.aspx Page
Instead of changing the master page named minimal.master,
it is also possible to add the top navigation bar directly to the
layout of the page. This can be done by adding the following code to the
SearchMain.aspx page layout.
Begin to edit the page by selecting Edit in Advanced Mode (using SPD 2010). Then locate this section in the SearchMain.aspx page. Also do the same for SearchResults.aspx.
</ContentTemplate>
</SharePoint:UIVersionedContent>
<SharePoint:UIVersionedContent UIVersion="4" runat="server">
<ContentTemplate>
Add the markup shown in Listing 3
just after the markup shown previously. This way the navigation is
added in the right place to make it show exactly as if it were added to
the master page using the previously described method.
Example 3. Navigation Markup Added to SearchMain.aspx Page
<div class="s4-lp s4-toplinks" style="background-image:url(/_layouts/images/selbg.png); background-repeat:no-repeat; repeat-x:left top; background-color:#f6f6f6; vertical-align:middle; min-height:25px; border-top:1px solid #e0e0e0; border-bottom:1px solid #b8babd"> <SharePoint:AspMenu ID="TopNavigationMenuV4" Runat="server" EnableViewState="false" DataSourceID="topSiteMap"
AccessKey="<%$Resources:wss,navigation_accesskey%>" UseSimpleRendering="true" UseSeparateCss="false" Orientation="Horizontal" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="1" SkipLinkText="" CssClass="s4-tn"/> <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate"> <Template_Controls> <asp:SiteMapDataSource ShowStartingNode="False" SiteMapProvider="SPNavigationProvider" id="topSiteMap" runat="server" StartingNodeUrl="sid:1002"/> </Template_Controls> </SharePoint:DelegateControl> </div>
|
In the foregoing sample, all the CSS styles come from the SharePoint CSS file named corev4.css. These can be changed to fit other requirements for the look of the page. After these changes, the SearchMain.aspx and SearchResults.aspx pages now include navigation as seen in Figure 6. As it is only the search center that uses SearchMain.aspx and SearchResults.aspx, it is suggested that this page is deployed throughout the farm to solve the missing navigation issue once and for all.
Also notice that the end result
from a user's perspective is exactly the same as when adding navigation
directly to the master page.